package com.hxx.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hxx.entity.TrainSeatEntity;
import com.hxx.service.TrainSeatService;
import com.hxx.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/trainSeat")
public class TrainSeatController {
    @Autowired
    private TrainSeatService trainSeatService;


    @GetMapping("page")
    public R listPage(Page page, TrainSeatEntity trainSeat) {
        trainSeatService.listPage(page, trainSeat);
        return R.ok().data("list",page.getRecords())
                .data("total",page.getTotal());
    }

    @PostMapping("save")
    public R add(@RequestBody TrainSeatEntity trainSeat) {
        trainSeatService.save(trainSeat);
        return R.ok();
    }

    @PutMapping("update")
    public R update(@RequestBody TrainSeatEntity trainSeat) {
        trainSeatService.updateById(trainSeat);
        return R.ok();
    }

    @DeleteMapping("delete/{id}")
    public R delete(@PathVariable Long id) {
        trainSeatService.removeById(id);
        return R.ok();
    }
}





















